/**
 * Created by zxc on 2017/6/20.
 */
//改变字体
$(document).ready(
    function () {
        $(".tab a").click(function () {
            $(this).addClass("currentli").siblings().removeClass("currentli");
        })
    });

$(document).ready(
    function () {
        $(".tabs li").click(function () {
            $(this).addClass("backli").siblings().removeClass("backli");
        })
    });


//table切换
$(document).ready(function() {
//Default Action
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content
//On Click Event
    $("ul.tabs li").click(function() {
        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });
});





$(document).ready(function() {

    //Default Action
    $(".tabs_content").hide(); //Hide all content
    $("ul.tabs_0 li:first").addClass("active").show(); //Activate first tab
    $(".tabs_content:first").show(); //Show first tab content

//On Click Event
    $("ul.tabs_0 li").click(function() {
        $("ul.tabs_0 li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tabs_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });

});

$(document).ready(function() {

    //Default Action
    $(".tabs_content_1").hide(); //Hide all content
    $("ul.tabs_1 li:first").addClass("active").show(); //Activate first tab
    $(".tabs_content_1:first").show(); //Show first tab content

//On Click Event
    $("ul.tabs_1 li").click(function() {
        $("ul.tabs_1 li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tabs_content_1").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });

});
$(document).ready(function() {

    //Default Action
    $(".tabs_content_2").hide(); //Hide all content
    $("ul.tabs_2 li:first").addClass("active").show(); //Activate first tab
    $(".tabs_content_2:first").show(); //Show first tab content

//On Click Event
    $("ul.tabs_2 li").click(function() {
        $("ul.tabs_2 li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tabs_content_2").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });

});






//图片轮播

$(document).ready(function() {
    var length,
        currentIndex = 0,
        interval,
        hasStarted = false, //是否已经开始轮播
        t = 6000; //轮播时间间隔
    length = $('.slider-panel').length;

    //将除了第一张图片隐藏
    $('.slider-panel:not(:first)').hide();
    //将第一个slider-item设为激活状态
    $('.slider-item:first').addClass('slider-item-selected');
    //隐藏向前、向后翻按钮
    $('.slider-page').hide();

    //鼠标上悬时显示向前、向后翻按钮,停止滑动，鼠标离开时隐藏向前、向后翻按钮，开始滑动
    $('.slider-panel, .slider-pre, .slider-next').hover(function() {
        stop();
        $('.slider-page').show();
    }, function() {
        $('.slider-page').hide();
        start();
    });

    $('.slider-item').hover(function(e) {
        stop();
        var preIndex = $(".slider-item").filter(".slider-item-selected").index();
        currentIndex = $(this).index();
        play(preIndex, currentIndex);
    }, function() {
        start();
    });

    $('.slider-pre').unbind('click');
    $('.slider-pre').bind('click', function() {
        pre();
    });
    $('.slider-next').unbind('click');
    $('.slider-next').bind('click', function() {
        next();
    });

    /**
     * 向前翻页
     */
    function pre() {
        var preIndex = currentIndex;
        currentIndex = (--currentIndex + length) % length;
        play(preIndex, currentIndex);
    }
    /**
     * 向后翻页
     */
    function next() {
        var preIndex = currentIndex;
        currentIndex = ++currentIndex % length;
        play(preIndex, currentIndex);
    }
    /**
     * 从preIndex页翻到currentIndex页
     * preIndex 整数，翻页的起始页
     * currentIndex 整数，翻到的那页
     */
    function play(preIndex, currentIndex) {
        $('.slider-panel').eq(preIndex).fadeOut(500)
            .parent().children().eq(currentIndex).fadeIn(1000);
        $('.slider-item').removeClass('slider-item-selected');
        $('.slider-item').eq(currentIndex).addClass('slider-item-selected');
    }

    /**
     * 开始轮播
     */
    function start() {
        if(!hasStarted) {
            hasStarted = true;
            interval = setInterval(next, t);
        }
    }
    /**
     * 停止轮播
     */
    function stop() {
        clearInterval(interval);
        hasStarted = false;
    }

    //开始轮播
    start();
});



$(function() {



    //车模

    //鼠标移入样式
    $(".sr_accordion>ul>li").mouseover(function () {
        $(this).addClass("active");
        $(this).siblings().removeClass("active");
    });

    function sjx(hgk,nmb){
        $(hgk).click(function(){
            $(this).children().addClass('greenx').parent().siblings().children().removeClass('greenx');
            var index=$(this).index();
            $(nmb).eq(index).fadeIn().siblings().hide();
        })
    }
    var j1=$('.jj1'),btb1=$('.b_tri_box1');
    sjx(j1,btb1);
    var j2=$('.jj2'),btb2=$('.b_tri_box2');
    sjx(j2,btb2);
    var j3=$('.jj3'),btb3=$('.b_tri_box3');
    sjx(j3,btb3);

    $('.sjx_kk').click(function(){
        $(this).children('.sjx_tri').fadeIn().parent().siblings().children('.sjx_tri').hide();
    });

});


/*三角型切换*/




